#include <assert.h>
#include "berkeley/moredb.h"
#include "lang/morestdlib.h"
#include "lang/morestring.h"

int berkeleyPackString(DBT* dbt,const char* str)
	{
	assert(dbt!=NULL);
	assert(str!=NULL);
	return berkeleyPack(dbt,str,1+strlen(str));
	}

int berkeleyPack(DBT* dbt,const void* ptr,size_t len)
	{
	void *p;
	assert(dbt!=NULL);
	assert(ptr!=NULL);
	p=Realloc(dbt->data,dbt->size+len);
	if(p==NULL) return -1;
	dbt->data=p;
	memcpy(&(dbt->data[dbt->size]),ptr,len+1);
	dbt->size+=len;
	return 0;
	}

